package cn.tp.ksoft.civil_driver.module.mime;

import android.os.Bundle;
import android.text.InputFilter;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import cn.tp.ksoft.civil_driver.view.simple.SimpleTextWatcher;
import cn.tp.ksoft.civil_driver.DriverBaseActivity;
import cn.tp.ksoft.civil_driver.R;

/**
 * Created by zhusong on 16/5/2.
 */
public class FeedbackActivity extends DriverBaseActivity implements View.OnClickListener{

    private final int TEXT_ALLOWED_LENGTH = 200; //默认文本可以输入的长度

    private EditText mFeedbackEdt;
    private TextView mRemainTv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.driver_activity_feedback);
        updateTitle(getString(R.string.driver_feedback));
        findViewById(R.id.btn_submit).setOnClickListener(this);
        mFeedbackEdt = (EditText) findViewById(R.id.edt_feedback);
        mFeedbackEdt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(TEXT_ALLOWED_LENGTH)});
        mRemainTv = (TextView) findViewById(R.id.tv_remain);
        mRemainTv.setText(getString(R.string.driver_feedback_remain_count, TEXT_ALLOWED_LENGTH));
        mFeedbackEdt.addTextChangedListener(new SimpleTextWatcher(){
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                super.onTextChanged(s, start, before, count);
                String content = s.toString();
                int contentLength=content.length();
                String text = getString(R.string.driver_feedback_remain_count, TEXT_ALLOWED_LENGTH - contentLength);
                mRemainTv.setText(text);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_submit : {
                finish();
                break;
            }
        }
    }
}
